package com.qw.soul.permission.support;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;

import com.qw.soul.permission.PermissionRequestCode;
import com.qw.soul.permission.support.manufacturer.HUAWEI;
import com.qw.soul.permission.support.manufacturer.MEIZU;
import com.qw.soul.permission.support.manufacturer.OPPO;
import com.qw.soul.permission.support.manufacturer.PermissionsPage;
import com.qw.soul.permission.support.manufacturer.Protogenesis;
import com.qw.soul.permission.support.manufacturer.VIVO;
import com.qw.soul.permission.support.manufacturer.XIAOMI;

/**
 * Created by joker on 2017/8/4.
 */

public class PermissionsPageManager
{
    public static final String MANUFACTURER_HUAWEI = "huawei";
    public static final String MANUFACTURER_XIAOMI = "xiaomi";
    public static final String MANUFACTURER_OPPO = "oppo";
    public static final String MANUFACTURER_VIVO = "vivo";
    public static final String MANUFACTURER_MEIZU = "meizu";

    static final String manufacturer = Build.MANUFACTURER;

    public static Intent getIntent(Context context)
    {
        PermissionsPage permissionsPage = new Protogenesis(context);
        if (MANUFACTURER_HUAWEI.equalsIgnoreCase(manufacturer))
        {
            permissionsPage = new HUAWEI(context);
        } else if (MANUFACTURER_OPPO.equalsIgnoreCase(manufacturer))
        {
            permissionsPage = new OPPO(context);
        } else if (MANUFACTURER_VIVO.equalsIgnoreCase(manufacturer))
        {
            permissionsPage = new VIVO(context);
        } else if (MANUFACTURER_XIAOMI.equalsIgnoreCase(manufacturer))
        {
            permissionsPage = new XIAOMI(context);
        } else if (MANUFACTURER_MEIZU.equalsIgnoreCase(manufacturer))
        {
            permissionsPage = new MEIZU(context);
        }
        return permissionsPage.settingIntent();
    }

    public static void jumpPermissionManager(Activity context)
    {
        context.startActivityForResult(getIntent(context), PermissionRequestCode.DEFAULT_CODE_APPLICATION_SETTINGS);
    }

    public static String getManufacturer()
    {
        return manufacturer;
    }

    public static boolean isXIAOMI()
    {
        return getManufacturer().equalsIgnoreCase(MANUFACTURER_XIAOMI);
    }

    public static boolean isOPPO()
    {
        return getManufacturer().equalsIgnoreCase(MANUFACTURER_OPPO);
    }

    public static boolean isMEIZU()
    {
        return getManufacturer().equalsIgnoreCase(MANUFACTURER_MEIZU);
    }
}
